package com.cw.carwashemployee.service.impl;

import com.cw.carwashemployee.domain.Employee;
import com.cw.carwashemployee.mapper.EmployeeMapper;
import com.cw.carwashemployee.service.EmployeeService;
import com.ruoyi.common.core.context.SecurityContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public List<Employee> selectemployeeList(Employee employee) {
        return employeeMapper.selectemployeeList(employee);
    }

    @Override
    public Long selectemployeeCount(Employee employee) {
        return employeeMapper.selectemployeeCount(employee);
    }

    @Override
    public Employee selectemployeeById(Long id) {
        return employeeMapper.selectemployeeById(id);
    }

    @Override
    public int insertemployee(Employee employee) {
        employee.setCreatedBy(SecurityContextHolder.getUserId());
        employee.setCreatedAt(new Date());
        return employeeMapper.insertemployee(employee);
    }

    @Override
    public int updateemployee(Employee employee) {
        employee.setUpdatedBy(SecurityContextHolder.getUserId());
        employee.setUpdatedAt(new Date());
        return employeeMapper.updateemployee(employee);
    }

    @Override
    public int deleteemployeeById(Long id) {
        return employeeMapper.deleteemployeeById(id);
    }

    @Override
    public int deleteemployeeByIds(Long[] ids) {
        return employeeMapper.deleteemployeeByIds(ids);
    }
}
